CREATE PROCEDURE showNotSentTable
@option INT,
@loginName VARCHAR(15),
@timeCreated DATE
AS
BEGIN
	IF(@option = 0)
	BEGIN
		SELECT Employee.Emp_Id,Lost_Connection.Login_Name,Employee.Emp_Mail,Employee.Time_Created,Lost_Connection.Connected FROM Lost_Connection	
		INNER JOIN Employee ON Lost_Connection.Login_Name = Employee.Login_Name		
	END
	
	ELSE IF(@option = 1)
	BEGIN
		SELECT Employee.Emp_Id,Lost_Connection.Login_Name,Employee.Emp_Mail,Employee.Time_Created,Lost_Connection.Connected FROM Lost_Connection	
		INNER JOIN Employee ON Lost_Connection.Login_Name = Employee.Login_Name		
		WHERE CourierDatabase.dbo.Employee.Login_Name = @loginName				
	END
	
	ELSE IF(@option = 2)
	BEGIN
		SELECT Employee.Emp_Id,Lost_Connection.Login_Name,Employee.Emp_Mail,Employee.Time_Created,Lost_Connection.Connected FROM Lost_Connection	
		INNER JOIN Employee ON Lost_Connection.Login_Name = Employee.Login_Name	
		WHERE CourierDatabase.dbo.Employee.Time_Created = @timeCreated	
	END
	
	ELSE
	BEGIN
		SELECT Employee.Emp_Id,Lost_Connection.Login_Name,Employee.Emp_Mail,Employee.Time_Created,Lost_Connection.Connected FROM Lost_Connection	
		INNER JOIN Employee ON Lost_Connection.Login_Name = Employee.Login_Name	
		WHERE CourierDatabase.dbo.Employee.Login_Name = @loginName	
		AND CourierDatabase.dbo.Employee.Time_Created = @timeCreated	
	END
END
GO

CREATE PROCEDURE AddConnection
@loginName VARCHAR(15)
AS
BEGIN
	INSERT INTO CourierDatabase.dbo.Lost_Connection(Login_Name,Connected) VALUES(@loginName,0)
END
GO

CREATE PROCEDURE GetInfoConnection
@loginName VARCHAR(15)
as
BEGIN
	SELECT Employee.Emp_Mail,Lost_Connection.Login_Name
	FROM Employee INNER JOIN Lost_Connection ON Lost_Connection.Login_Name = Employee.Login_Name
	WHERE Lost_Connection.Login_Name = @loginName
END
GO
